#include<iostream>
using namespace std;
int samePre(int x,int y){
	if(x==y){
		return x;
	}else if(x>y){
		return samePre(x/2,y);
	}else{
		return samePre(x,y/2);
	}
}
int main(){
	int x,y;
	cin>>x>>y;
	cout<<samePre(x,y);
}
